package com.cll.prototype.sharding.jdbc.repository;

import com.cll.prototype.sharding.jdbc.dto.PositionDto;
import com.cll.prototype.sharding.jdbc.entity.Position;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

/**
 * 描述信息:
 *
 * @author CLL
 * @version 1.0
 * @date 2020/11/21 23:13
 */
public interface PositionRepository extends JpaRepository<Position, Long> {

    /**
     * 根据主键查询
     * @param id    主键
     * @return  传输的完整的逻辑对象
     */
    @Query(nativeQuery = true, value = "select p.id,p.name,p.salary,p.city,pd.description from position p join position_detail pd on(p.id=pd.pid) where p.id=:id")
    Object getById(@Param("id") long id);
}